package cn.org.rookie.jeesdp.mapper.utils;

import java.lang.reflect.Field;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;

/**
 * @author LHT
 */

public abstract class ObjectUtils {

    private ObjectUtils() {
    }

    public static List<Field> getAllFields(Class<?> type) {
        List<Field> fields = new ArrayList<>();

        Class<?> superclass = type.getSuperclass();
        if (!superclass.equals(Object.class)) {
            fields.addAll(getAllFields(superclass));
        }
        fields.addAll(Arrays.asList(type.getDeclaredFields()));
        return fields;
    }
}
